<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 供应商产品报价信息</title>
	<%@include file="/WEB-INF/jsp/include/meta.jsp"%>
	
	<link href="<%=basePath%>css/public.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/index.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/pagebar.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/supplierQuotationService.js"></script>
</head>

<body oncontextmenu='return false'>




	<!--right begin-->
    <div class="fl right">
    
    		<!--产品详细信息 begin-->	
    		<div class="titleBg">
            	<div class="fl"><img src="images/rightTitleLeft.jpg" alt="left" /></div>
            	<div class="fl title"><span class="marking1"></span>公司信息</div>
                <div class="fr"><img src="images/rightTitleRight.jpg" alt="left" /></div>
            </div>
            <div id="clear"></div>
            
            <div class="rightBorder">
            

                <div class="property1">
                <table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#dfe5e9">
                      <tr>
                        <td width="10%" align="right" bgcolor="#dfe5e9">公司名称：</td>
                        <th width="30%" align="left" bgcolor="#dfe5e9">${supplier.companyName}&nbsp;</th>                        
                        <td width="10%" align="right" bgcolor="#dfe5e9">联系人：</td>
                        <th align="left" bgcolor="#dfe5e9">${supplier.contact}&nbsp;</th>
                        <td width="10%" align="right">联系电话：</td>
                        <th align="left" bgcolor="#dfe5e9">${supplier.tel}&nbsp;</th>
                      </tr>
                    
                  <tr>
                    <td align="right">地   址：</td>
                    <th align="left"><label title="${supplier.address}">${fne:subStringB(supplier.address,'...',0,16)}</th>
                    <td align="right">手　机：</td>
                    <th align="left" bgcolor="#dfe5e9">${supplier.mobile}&nbsp;</th>
                    <td align="right">邮　　箱：</td>
                    <th align="left">${supplier.email}&nbsp;</th>
                  </tr>
                  <tr>
                    <td align="right">网    址：</td>
                    <th align="left">${supplier.website}&nbsp;</th>
                    <td align="right">QQ：</td>
                    <th align="left" colspan="3">${supplier.qq}&nbsp;</th>
                  </tr>
                  <tr>
                    <td align="right">公司介绍：</td>
                    <th align="left"><label title="${supplier.detail}">${fne:subStringB(supplier.detail,'...',0,16)}</label></th>
                    <td align="right">备   注：</td>
                    <th align="left" colspan="3"><label title="${supplier.remark}">${fne:subStringB(supplier.remark,'...',0,20)}</label></th>                    
                  </tr>
                  </table>

                
      </div>
                <div id="clear"></div>
            
            </div>
            <!--产品详细信息 end-->
 
 
    		<!--供应商 begin-->	
    		<div class="titleBg">
            	<div class="fl"><img src="images/rightTitleLeft.jpg" alt="left" /></div>
            	<div class="fl title"><span class="marking1"></span>产品报价信息</div>
                <div class="fr"><img src="images/rightTitleRight.jpg" alt="left" /></div>
            </div>
            <div id="clear"></div>
            
            <div class="rightPropertyList">
            	<div class="title1">
                <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#dfe5e9">
                  <tr>
                    <th width="3%" align="center"><input type="checkbox" name="allSelectId" id="allSelectId" onclick="judgmentChecjBox('allSelectId','id')" /></th>
                    <th width="8%">报价时间</th>
                    <th width="8%">录入</th>
                    <th width="12%">货号</th>
                    <th width="6%">价格</th>
                    <th width="24%">品质规格</th>                    
                    <th width="13%">供应商名称</th>
                    <th width="4%">长</th>
                    <th width="4%">宽</th>
                    <th width="4%">高</th>                    
                    <th width="4%">毛重</th>
                    <th width="4%">净重</th>
                    <th width="6%">每箱数量</th>
                  </tr>
                  <!-- 
                </table>
                </div>
                <div class="list">
                <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#dfe5e9">
                 -->
                 <c:forEach var="data" items="${supplierQuotationList}">
                  <tr>
                    <td width="3%" align="center"><input type="checkbox" value="${data.id}" name="id" /></td>
                    <td width="8%" align="center"><fmt:formatDate value="${data.quoteTime}" pattern="yyyy-MM-dd"/></td>
                    <td width="8%" align="center">${data.user.userName}</td>
                    <td width="12%" align="center">${data.product.productNo}</td>
                    <td width="6%" align="center">${data.price}</td>
                    <td width="24%" align="center"><label title="${data.qualitySpecifications}">${fne:subStringB(data.qualitySpecifications,'...',0,20)}</label></td>                    
                    <td width="13%">${data.supplier.companyName}</td>
                    <td width="4%" align="center">${data.packingLong}</td>
                    <td width="4%" align="center">${data.packingWidth}</td>
                    <td width="4%" align="center">${data.packingHeight}</td>
                    <td width="4%" align="center">${data.grossWeight}</td>
                    <td width="4%" align="center">${data.netWeight}</td>
                    <td width="6%" align="center">${data.boxes}</td>               
                  </tr>
                  </c:forEach>
				  <c:if test="${empty supplierQuotationList}"><tr><td colspan="13" style="text-align:center">没有相关记录！</td></tr></c:if> 
              </table>
              </div>
            </div>
            <!--供应商 end-->


            <!--统计 end-->
            <div class="total">
                <div class="fl Statistics">总数：<strong>${searchStat.totalCount}</strong> 条
                 <script type="text/javascript">
				var pageControl = new wpagebar('pageControl');
				pageControl.argName = "pageIndex";
				pageControl.pageCount = ${searchStat.pageCount};
				pageControl.load();
				</script> 
                </div>
                <div class="fr Operating">
                	<c:if test="${not empty supplier}">
                    <ul>
                        <!-- <li><input name="复 制" type="button" class="button" value="复 制" /></li> -->
                        <li><input name="添 加" type="button" class="button" value="添 加" onclick="addQuotation(${supplier.id})"/></li>
                        <li><input name="修 改" type="button" class="button" value="修 改" onclick="editQuotations(${supplier.id})"/></li>
                        <c:if test="${sessionScope.memberSessionInfo.userType.value eq '0'}">
                        <li><input name="删 除" type="button" class="button" value="删 除" onclick="delsellMultiple()"/></li>
                        </c:if>
                        <li><input name="生成EXL表" type="button" class="button" value="导出EXCEL" onclick="exportExcel()"/></li>
                    </ul>
                	</c:if>                
                </div>
            </div>
 
            <!--统计 end-->
            
            <div id="win_temp" style="display:none">
				<div id="shipDiv"><iframe name="shipDivFrame" id="shipDivFrame" frameborder="0" scrolling="no" width="600" height="350"></iframe></div>
			</div>    
    <script src="<%=basePath%>js/win.js" type="text/javascript"></script>
    </div>
	<!--right end-->

<script  type="text/javascript">
function exportExcel(){			
	var ids = getSelectedCheckBoxValues('id');
	if(ids == "")
		alert("请先选择要导出的信息！");
	else {
		window.open("<%=basePath%>trade/exportExcel?t=4&ids="+ids);
	}
}
function addQuotation(){
	WIN.show('<font size=5>添加供应商产品报价信息</font>',$('winCon_1'),{width:600,height:350});
}
function addQuotation(id){
	if(id==''){
		 alert("请先选择供应商信息!");
		 return;
	}		
	WIN.show('<font size=5>添加供应商产品报价信息</font>',$('shipDiv'),{width:600,height:350});
	$("shipDivFrame").src="<%=basePath%>trade/supplierQuotationEdit?action=add&sid="+id;
}
function editQuotation(id){
	WIN.show('<font size=5>修改供应商产品报价信息</font>',$('winCon_1'),{width:600,height:400});
	supplierQuotation.getSupplierQuotationById(id,function(data){
		$('userId0').value=data.id;
		$('userName0').value=data.userName;
		if(data.sex){$N('sex0')[0].checked=true;}else{$N('sex0')[1].checked=true;}
		$('telphone0').value=data.telphone;
		$('dept0').value=data.department.id;		
		$('account0').value=data.account;
		$('role0').value=data.role.id;
		if(data.status){$N('status0')[0].checked=true;}else{$N('status0')[1].checked=true;}		
	})
}
function delsellMultiple(){			
	var objs = document.getElementsByName("id");
	var ids='';	
	for(var i=0;i<objs.length;i++){
		if(objs[i].checked){
			ids+=objs[i].value+",";
		}
	}
	if(ids==''){
		alert("请先选择要操作的信息");
		return ;
	}
	ids = ids.substring(0,ids.length - 1);
	
	if(confirm("您确定要删除?")){
		if(ids == ""){
			alert("请先选择要删除的信息！");
			return false;
		}else{
			supplierQuotationService.deleteSupplierQuotationByIds(ids,{
				callback:function(f){alert("删除成功");reload();},
				exceptionHandler:function(message){alert("删除失败，请重试");},
				errorHander:function(err){}
			})
		}
	}
}

function editQuotations(){
	var objs = document.getElementsByName("id");	
	var ids=0;
	var vas='';
	for(var i=0;i<objs.length;i++){
		if(objs[i].checked){
			ids++;
			vas=objs[i].value;			
		}
	}
	if(ids!=1){
		alert("请选择一条且只能选择一条信息进行编辑！");
		return ;
	}	
	if(vas==''){
		alert("请先选择要操作的信息");
		return ;
	}else{
		WIN.show('<font size=5>修改供应商报价信息</font>',$("shipDiv"),{width:600,height:350,afterClose:function(){reload();}});
		$("shipDivFrame").src="<%=basePath%>trade/supplierQuotationEdit?action=modify&id="+vas;
	}	
}
function delQuotation(id){
	if(confirm("删除用户，将导致用户无法登陆，确定删除 ？")){
		WIN.showpg();
		userService.delUserById(id,{
			callback:function(f){WIN.closepg();alert("删除成功");reload();},
			exceptionHandler:function(message){WIN.closepg();alert("删除失败，请重试");},
			errorHander:function(err){}
		})
	}
}

function submitQuotation(){
	var user={
			id:			$('userId0').value,
			name:		$('name0').value,
			sex:		$N('sex0')[0].checked,
			telphone:	$('telphone0').value,
			dept:		{id:$('dept0').value},
			sign:		$('sign0').value.trim(),
			userType:	$('type0').value,
			status:		$N('status0')[0].checked
	}
	
	if(''==user.sign){alert('账号不能为空');return;}
	if(''==user.dept.id){alert('请选择部门');return;}
	
	if(''==user.id){
		submitUser.user=user;		
		userService.hasSign(user.sign,{
			callback:function(f){if(f){alert('此账号已经存在，请更改');}else{submit(submitUser.user);}},
			exceptionHandler:function(message){WIN.closepg();alert(message);alert("操作失败，请重试");reload();},
			errorHander:function(err){}
		})
	}else{
		submit(user);
	}
}
function submit(data){
	WIN.close();
	WIN.showpg();
	supplierQuotation.editSupplierQuotation(data,{
		callback:function(f){WIN.closepg();alert("操作成功");reload();},
		exceptionHandler:function(message){WIN.closepg();alert(message);alert("操作失败，请重试");},
		errorHander:function(err){}
	})
}
function submitStock(){
	WIN.win.style.display="none";
	WIN.winBg.style.display="none";
	WIN.showpg();
}
function afterSubmit(){
	reload();
}
</script>
</body>
</html>
